from django.conf.urls import patterns, include, url

from userena import urls as userena_urls
from userena import views as userena_views

from .forms import ProfileForm, ProfilePasswordChangeForm, ProfileChangeEmailForm, ProfileSignupForm, ProfileAuthenticationForm
from . import views as profile_views

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',    
    
    # Signup, signin and signout
    url(r'^signup/$',
       userena_views.signup,
       {'template_name': 'profiles/profile_signup_form.html'
            , 'signup_form': ProfileSignupForm},
       name='userena_signup'),
    url(r'^signin/$',
       userena_views.signin,
       {'template_name': 'profiles/profile_signin_form.html'
            , 'auth_form': ProfileAuthenticationForm},
       name='userena_signin'),
    url(r'^signout/$',
      userena_views.signout,
      {'template_name': 'profiles/profile_signout.html'},
      name='userena_signin'),
       
    # Profile Avatar, and Avatar cropping
    url(r'^(?P<username>[\.\w-]+)/avatar/$',
        profile_views.ProfieAvatarUpdateView.as_view(),
        name='avatar'),
        
    # Edit profile to user Custom profiles.forms.ProfileForm
    url(r'^(?P<username>[\.\w-]+)/edit/$',
       userena_views.profile_edit, 
       {'template_name': 'profiles/profile_form.html'
            , 'edit_profile_form': ProfileForm},
       name='userena_profile_edit'),

    # Change email and confirm it
    url(r'^(?P<username>[\.\w-]+)/email/$',
       userena_views.email_change,
       {'template_name': 'profiles/profile_email_form.html'
            , 'email_form': ProfileChangeEmailForm},
       name='userena_email_change'),
      
    # Change password
    url(r'^(?P<username>[\.\w-]+)/password/$',
       userena_views.password_change,
       {'template_name': 'profiles/profile_password_form.html'
            , 'pass_form': ProfilePasswordChangeForm},
       name='userena_password_change'),
      
    # View specific profiles
    url(r'^(?P<username>(?!signout|signup|signin)[\.\w-]+)/$',
        userena_views.profile_detail,
        {'template_name': 'profiles/profile_detail.html'},
        name='userena_profile_detail'),
        
    # Profile List
    url(r'^$', profile_views.ProfileAjaxListView.as_view(),
        name='userena_profile_list'),
)

# Then add other from userena.urls.urlpatterns
urlpatterns = urlpatterns + userena_urls.urlpatterns
